<!DOCTYPE html>
<html class="signin no-js" lang="${lang!}">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <meta name="description" content="${AppName!}">
    <meta name="keywords" content="nutz,nutzwk">
    <title>${AppName!}</title>
    <link rel="stylesheet" href="${base!}/assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${base!}/assets/css/font-awesome.css">
    <link rel="stylesheet" href="${base!}/assets/css/themify-icons.css">
    <link rel="stylesheet" href="${base!}/assets/css/animate.min.css">
    <link rel="stylesheet" href="${base!}/assets/css/skins/palette.css">
    <link rel="stylesheet" href="${base!}/assets/css/fonts/font.css">
    <link rel="stylesheet" href="${base!}/assets/css/main.css">
    <!--[if lt IE 9]>
    <script src="${base!}/assets/js/html5shiv.js"></script>
    <script src="${base!}/assets/js/respond.min.js"></script>
    <script src="${base!}/assets/js/json2.js"></script>
    <![endif]-->
    <script src="${base!}/assets/plugins/modernizr.js"></script>
    <script src="${base!}/assets/plugins/jquery-1.11.1.min.js"></script>
    <script src="${base!}/assets/js/jquery.pjax.js"></script>
    <script src="${base!}/assets/js/sso/RSA.js"></script>
    <script src="${base!}/assets/js/sso/BigInt.js"></script>
    <script src="${base!}/assets/js/sso/Barrett.js"></script>

<body>
<div class="overlay"></div>
<div class="center-wrapper">
    <div class="center-content">
        <div class="row no-m">
            <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
                <section class="panel bg-white no-b fadeIn animated">
                    <header class="panel-heading no-b text-center" style="font-size:30px;">
                        ${AppName!}
                    </header>
                    <!-- START Language list-->
                    <ul class="nav navbar-nav navbar-right">
                        <li class="language-dropdown dropdown hidden-xs">
                            <a href="javascript:;" data-toggle="dropdown" id="language">
                                <%if(lang==null||lang=="zh_CN"){%>
                                <img src="${base!}/assets/img/flags/cn.png" class="flag">
                                <span class="language">中文</span>
                                <%}else{%>
                                <img src="${base!}/assets/img/flags/us.png" class="flag">
                                <span class="language">English</span>
                                <%}%>
                                <ul class="dropdown-menu dropdown-menu-right animated fadeInUp">
                                    <li>
                                        <a href="?lang=en_US">
                                            <img src="${base!}/assets/img/flags/us.png" class="flag">
                                            <span class="language">English</span>
                                        </a>
                                    </li>
                                    <li>
                                        <a href="?lang=zh_CN">
                                            <img src="${base!}/assets/img/flags/cn.png" class="flag">
                                            <span class="language">中文</span>
                                        </a>
                                    </li>
                                </ul>
                        </li>
                    </ul>
                    <!-- END Language list    -->
                    <div class="p15">
                        <form id="loginForm" action="${base!}/platform/login/doLogin" data-parsley-validate="" novalidate=""
                              role="form"
                              method="post">
                            <input type="hidden" id="platformCaptcha" name="platformCaptcha">

                            <div class="form-group">
                                <input type="text" id="username" name="username" value="superadmin" required
                                       class="form-control input-lg mb25"
                                       placeholder="${msg['login.username']}">
                            </div>
                            <div class="form-group">
                                <input type="password" id="password" name="password" value="1" required
                                       class="form-control input-lg mb25"
                                       placeholder="${msg['login.password']}">
                            </div>
                            <p id="tip" class="bg-danger p15" style="display:none"></p>

                            <div class="show">
                                <button id="login" class="btn btn-primary btn-lg btn-block" type="button"
                                        data-loading-text="${msg['login.submit']}...">
                                    ${msg['login.submit']}
                                </button>
                            </div>
                        </form>
                    </div>
                </section>
                <p class="text-center text-default">
                    Copyright &copy;
                    <span id="year" class="mr5"></span>
                </p>
            </div>
        </div>

    </div>
</div>
<!-- 验证码 -->
<div id="dialogVeryCode" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" style="color:black;">
                    ${msg['login.error.verifycode']}
                </h4>
            </div>
            <div class="modal-body">
                <form id="f2" onsubmit="return false;" data-parsley-validate="" novalidate="">
                    <div class="row">
                        <div class="col-xs-2"></div>
                        <div class="col-xs-6">
                            <input type="text" id="verifycode" required class="form-control input-lg"
                                   placeholder="${msg['login.captcha']}">
                        </div>
                        <div class="col-xs-4">
                            <img id="captcha_img" src="${base!}/platform/login/captcha" style="height:46px;cursor: pointer;"
                                 onclick="$('#captcha_img').attr('src', '${base!}/platform/login/captcha?_=' + new Date().getTime())"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button id="ok" type="button" class="btn btn-primary" data-dismiss="modal">${msg['login.submit']}
                </button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function bodyRSA()
    {
        setMaxDigits(200);
        return new RSAKeyPair("${publicKeyExponent!'10001'}","","${publicKeyModulus!'a5aeb8c636ef1fda5a7a17a2819e51e1ea6e0cceb24b95574ae026536243524f322807df2531a42139389674545f4c596db162f6e6bbb26498baab074c036777'}");
    }
    var key =  bodyRSA();
    $(document).ready(function () {
        $("#year").html(new Date().getFullYear());
        $(document).on('keypress',function(event){
            if(event.keyCode == 13){
                $("#password").val(encryptedString(key, $("#password").val().split("").reverse().join("")));
                $("#loginForm").submit();
            }
        });
        $("#login").on("click",function () {
            $("#password").val(encryptedString(key,$("#password").val().split("").reverse().join("")));
            $("#loginForm").submit();
        });
        $("#loginForm").ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").text("${msg['login.load']}");
                form.find("button:submit").attr("disabled", "disabled");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    $("#tip").hide();
                    form.find("button:submit").text("${msg['login.success']}");
                    window.location.href = "${base!}/platform/home";
                } else if (data.code == 2) {
                    $("#verifycode").val("");
                    $("#dialogVeryCode img").attr("src", '${base!}/platform/login/captcha?_=' + new Date().getTime());
                    return $("#dialogVeryCode").modal({show: true, backdrop: 'static', keyboard: false});
                } else {
                    $("#platformCaptcha").val("");
                    $("#password").val("").focus();
                    $('#captcha_img').attr('src', '${base!}/platform/login/captcha?_=' + new Date().getTime());
                    $("#tip").html(data.msg);
                    $("#tip").fadeIn();
                    form.find("button:submit").text("${msg['login.submit']}");
                    form.find("button:submit").removeAttr("disabled")
                }
            }
        });
        $("#ok").on("click", function () {
            if ($("#verifycode").val() == "") {
                $("#f2").submit();
                return false;
            }
            $("#platformCaptcha").val($("#verifycode").val());
            $("#loginForm").submit();
        });
        $("#dialogVeryCode").on("keypress", function (event) {
            var key = event.which;
            if (key == 13) {
                $("#ok").trigger("click");
            }
        });
        $("#username").focus();
    });
</script>


<script src="${base!}/assets/bootstrap/js/bootstrap.js"></script>
<script src="${base!}/assets/plugins/jquery.form.js"></script>
<script src="${base!}/assets/plugins/parsley.min.js"></script>
<script src="${base!}/assets/plugins/parsley.zh_cn.js"></script>

</body>
</html>